import 'package:flutter/material.dart';
import 'dart:math' as math;

/// 动画瓦片组件
class AnimatedTile extends StatelessWidget {
  final AnimationController animationController;
  final String text;
  
  const AnimatedTile({
    Key? key,
    required this.animationController,
    required this.text,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: animationController,
      builder: (context, child) {
        // 使用Transform.rotate实现旋转效果
        // 通过动画值控制旋转角度，实现抖动效果
        return Transform.rotate(
          // 将动画值映射到-5度到5度之间，产生抖动效果
          angle: (math.pi / 180) * (10 * animationController.value - 5),
          child: child,
        );
      },
      // 这是要抖动的图标
      child: Text(text),
    );
  }
}